﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using TTGameEngine;

/*
 * BattleUIHelper
 *
 *
 *
 * 依赖：
 *
 * ！不写重复代码！
 * @author TTun
 * @date 8/21/2017 9:41:59 AM
 */
namespace TTGame {

public class BattleUIHelper {
    Vector3 leftBottomPos;
    Vector3 UICameraWorldFieldofView;

    static BattleUIHelper ins;

    public static BattleUIHelper Share() {
        if(ins == null) {
            ins = new BattleUIHelper();
            ins.init();
        }
        return ins;
    }

    public void init() {
//         Camera UICamera = UGUIManager.GetInstance().m_Camera;
//         leftBottomPos = UICamera.ViewportToWorldPoint(Vector3.zero);
//         UICameraWorldFieldofView = UICamera.ViewportToWorldPoint(new Vector3(1, 1, 0)) - leftBottomPos;
//         UICameraWorldFieldofView.z = 0;
    }

    //游戏坐标转换 UI 坐标 ， 超出屏幕返回 False
    public bool CovertToUICoordinate(Vector3 gamePos, out Vector3 UIpos) {
//         if(TTGameEngine.BattleManager.Share() == null) {
//             UIpos = Vector3.zero;
//             return false;
//         }
//         Vector3 viewPoint = TTGameEngine.BattleManager.Share().getMainCamera().WorldToViewportPoint(gamePos);
//         if(viewPoint.x < -0.1f || viewPoint.x > 1.1f || viewPoint.y < -0.1f || viewPoint.y > 1.1f) {
//             UIpos = Vector3.zero;
//             return false;
//         } else {
//             //mark:test
//             //viewPoint.y -= 0.2f;
//             UIpos = leftBottomPos + Vector3.Scale(UICameraWorldFieldofView, viewPoint);
//             return true;
//         }
        UIpos = Vector3.zero;
        return true;
    }

//     public void ShowHurtEffect(HURTNUMTYPE type, Vector3 showDamagePos, int num = 0) {
//         if(type == HURTNUMTYPE.NORMALHURTNUM) {
//             if(num <= 0) {
//                 return;
//             }
//         }
//         Vector3 UIpos;
//         if(CovertToUICoordinate(showDamagePos, out UIpos)) {
//             if(UGUIBattleForm.getInstance() != null) UGUIBattleForm.getInstance().showHurtEffect(type, UIpos.x, UIpos.y, num);
//         }
//     }

//     public void ShowHp(bool isVisible, Vector3 showHpPos, float hpPrecent, int hpType) {
//         Vector3 UIpos;
//         if(CovertToUICoordinate(showDamagePos, out UIpos)) {
//             UGUIBattleForm.getInstance().showHurtEffect(type, UIpos.x, UIpos.y, num);
//         }
//     }

}

}
